<?php
//开发者发起退款
require_once 'sign.php';

// $timestamp = 1719889433;
$timestamp = time();
// 开发者填入自己的小程序 app_id
$appId = "ttdd96ab2b42a07b6d01";
$nonceStr = randStr(10);
$keyVersion = "3";
$url = "/api/apps/trade/v2/create_refund";
$data = json_encode([
    "out_order_no" => "LD1720747466669085ca487c1",
    "out_refund_no" => "tk1720747466669085ca487c1",
    // "cp_extra" => "extra_info",
    "order_entry_schema" => [
        "path" => "ext://microapp-trade-plugin/refund-detail",
        
    ],
    // "notify_url"=>"",
    "item_order_detail" => [
        [
            "item_order_id" => "ots73905540869716400765664",
            // "refund_amount" => 100
        ]
    ]
]);
$byteAuthorization = getByteAuthorization($url, $data, $appId, $nonceStr, $timestamp, $keyVersion);
$res = sign_post('https://developer.toutiao.com/api/apps/trade/v2/create_refund', $byteAuthorization, $data);
echo $res;
exit;